<?php

$mytrustdirname = basename( dirname( __FILE__ ) );
$mytrustdirpath = dirname( __FILE__ );

$language = empty($GLOBALS['xoopsConfig']['language']) ? 'english' : $GLOBALS['xoopsConfig']['language'];
$lang_dir = dirname(__FILE__) . '/language/';
if (file_exists($lang_file = $lang_dir . $language . '/main.php') || file_exists($lang_file = $lang_dir . 'english/main.php')) {
    include_once $lang_file;
}

//wanikoo
$modulename = "";
$modulename = $GLOBALS['mydirname'];

$mydownloads_theme = "mydownloads";

$mydownloads_allowed_theme = array("mydownloads", "mydownloads-RW", "mydownloads-LW", "mydownloads-BW", "wfdownloads", "wfdownloads-RW", "wfdownloads-LW", "wfdownloads-BW");

if (!empty($_POST['mydownloads_theme_select']) && in_array($_POST['mydownloads_theme_select'], $mydownloads_allowed_theme)) {
       		$mydownloads_theme = $_POST['mydownloads_theme_select'];
       		$_SESSION[$modulename.'D3UserTheme'] = $_POST['mydownloads_theme_select'];
} elseif (!empty($_SESSION[$modulename.'D3UserTheme']) && in_array($_SESSION[$modulename.'D3UserTheme'], $mydownloads_allowed_theme)) {
       		$mydownloads_theme = $_SESSION[$modulename.'D3UserTheme'];
}

//wanikoo
if( in_array($mydownloads_theme, $mydownloads_allowed_theme) ) {
$valid_theme = true;
}
else {
$valid_theme = false;
}

$mydownloads_wide_theme = false;
$mydownloads_right_wide_theme = false;
$mydownloads_left_wide_theme = false;
$mydownloads_both_wide_theme = false;

if ((strpos($mydownloads_theme, '-RW')||strpos($mydownloads_theme, '-w')) && ($valid_theme === true)) {
$mydownloads_wide_theme = true;
$mydownloads_right_wide_theme = true;
}
elseif (strpos($mydownloads_theme, '-LW') && ($valid_theme === true)) {
$mydownloads_wide_theme = true;
$mydownloads_left_wide_theme = true;
}
elseif (strpos($mydownloads_theme, '-BW') && ($valid_theme === true)) {
$mydownloads_wide_theme = true;
$mydownloads_both_wide_theme = true;
}

//wfdownloads-like
$tmppos = strpos($mydownloads_theme, 'wfdownloads');
if ( ($tmppos !== false) && ($valid_theme === true)) {
$mydownloads_wf_theme = true;
}
else {
$mydownloads_wf_theme = false;
}

//wanikoo

define('XOOPSMYDOWNLOADURL', XOOPS_URL."/modules/$modulename");
define('XOOPSMYDOWNLOADPATH', XOOPS_ROOT_PATH."/modules/$modulename");
define('XOOPSMYDOWNLOADINCURL', XOOPSMYDOWNLOADURL."/include");
define('XOOPSMYDOWNLOADINCPATH', XOOPSMYDOWNLOADPATH."/include");
define('XOOPSMYDOWNLOADIMGURL', XOOPSMYDOWNLOADURL."/images");
define('XOOPSMYDOWNLOADIMGPATH', XOOPSMYDOWNLOADPATH."/images");

include_once dirname( __FILE__ )."/include/functions.php";

//wanikoo
$mydownloads_show_extrafunc = true;
if (strpos($GLOBALS['xoopsRequestUri'],'singlefile.php')) {
$mydownloads_show_extrafunc_big = true;
}
else {
$mydownloads_show_extrafunc_big = false;
}

//ver3.0
$mydownloads_show_externalsearch = false;
$mydownloads_show_xoopssearch = true;

//ver2.0
$mydownloads_show_logo = true;
$mydownloads_show_toolbar = true;
$mydownloads_show_letters = true;
$mydownloads_show_search = true;
//ver3.0
$mydownloads_show_feed = true;
$mydownloads_show_themechanger = true;

$mydownloads_adcodes = array();
$mydownloads_adcodes['all'] = '';
$mydownloads_adcodes['index'] = '';
$mydownloads_adcodes['singlefile'] = '';
$mydownloads_adcodes['viewcat'] = '';
$mydownloads_adcodes['topten'] = '';
$mydownloads_adcodes['ratefile'] = '';
$mydownloads_adcodes['modfile'] = '';
$mydownloads_adcodes['brokenfile'] = '';
$mydownloads_adcodes['submit'] = '';

//wanikoo
// disallow=0, allow =1, memberonly =2
$mydownloads_can_print = 1;
$mydownloads_can_pdf = 1;
$mydownloads_can_bookmark = 1;
//if qrcode module exists 
if ( file_exists(XOOPS_ROOT_PATH."/modules/qrcode/qrcode_image.php") ) {
// disallow=0, allow =1, memberonly =2
$mydownloads_can_qrcode = 2;
}
else {
//no qrcode module
$mydownloads_can_qrcode = 0;
}

//logo
if ( $mydownloads_show_logo && !is_dir(XOOPSMYDOWNLOADIMGPATH."/".$mydownloads_theme."/logo-en.gif") && file_exists(XOOPSMYDOWNLOADIMGPATH."/".$mydownloads_theme."/logo-en.gif") ) {
	$logoimage = "<a href='".XOOPSMYDOWNLOADURL."/index.php'><img src='".XOOPSMYDOWNLOADIMGURL."/".$mydownloads_theme."/logo-en.gif' border='0' alt='' /></a>";
}
elseif ( $mydownloads_show_logo && !is_dir(XOOPSMYDOWNLOADIMGPATH."/logo-en.gif") && file_exists(XOOPSMYDOWNLOADIMGPATH."/logo-en.gif") ) {
	$logoimage = "<a href='".XOOPSMYDOWNLOADURL."/index.php'><img src='".XOOPSMYDOWNLOADIMGURL."/logo-en.gif' border='0' alt='' /></a>";
}
else {
	$logoimage = "";
}
?>